<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>开关灯</title>
    <script src="./js/indexs.js"></script>

    <script>
        window.addEventListener("load", function () {
            let bu = document.querySelector(".button");
            let flag = true;
            let h = document.querySelector("h3");
            let audio=document.querySelector(".ms");
            bu.addEventListener("click", function () {
                if (flag) {
                    document.body.style.backgroundColor = "black";
                    flag = false;
                    h.style.color = "rgb(255,255,255)";
                    audio.src="./Music/wan.mp3";
                    h.innerText = "点击灯泡开灯";

                } else {
                    document.body.style.backgroundColor = "rgb(255,255,255)";
                    flag = true;
                    h.style.color = "black";
                    h.innerText = "点击灯泡关灯";
                     audio.src="./Music/zao.mp3";
                }


            })


        });


    </script>
    <style>
        * {
            margin: 0;
            padding: 0;

        }

        @media screen and (min-width: 1500px) {
            html {
                font-size: 153px;
            }
        }
        html{
            height:100%;
        }

        body {
            transition: all 2s;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            height:100%;
        }

        .button {

            width: 2.30718954248366rem;
        }

        h3 {
            transition: all 2s;
            display: flex;
        }
    </style>
</head>

<body>

    <img class="button" src="././image/deng.png">
    <h3 style="font-size: 0.230718954248366rem;">点击灯泡关灯</h3>
    <audio src="./Music/zao.mp3" class="ms" autoplay="autoplay" loop="loop"></audio>
</body>

</html>